package com.hctforgreen.greenservice.model;

import java.util.ArrayList;

import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

/**
 * 大机组审核状态
 * 
 * @author 390694
 * 
 */
public class BigUnitPasswordStatusEntity extends BaseEntity {
	private static final long serialVersionUID = 439712719693268736L;
	/**
	 * 连接服务器的状态 0--成功，其他--失败
	 */
	public String statusCode = "";
	public String msg = "";

	/**
	 * 审核审核状态 0：未审核；1：通过；2：未通过
	 */
	public String examineStatus = "";
	/**
	 * 拒绝理由
	 */
	public String refuseReason = "";
	/**
	 * 开机密码
	 */
	public String bootPwd = "";
	
	
	public String identityCode = "";// 识别码
	public String barcode = "";
	public String searchDate = "";// 查询时间
	public String verifyStatus = "";// 确认状态 0：未确认；1：通过；2：未通过

	public final static String STATUS_CODE = "statusCode";
	public final static String MSG = "msg";

	public final static String EXAMINE_STATUS = "examineStatus";
	public final static String REFUSEREASON = "refuseReason";
	public final static String BOOT_PWD = "bootPwd";
	public final static String IDENTITY_CODE = "identityCode";
	public final static String BARCODE = "barcode";
	public final static String SEARCH_DATE = "searchDate";
	public final static String VERIFY_STATUS = "verifyStatus";

	public static BigUnitPasswordStatusEntity parse(JSONObject jsonObject)
			throws JSONException {
		BigUnitPasswordStatusEntity bean = new BigUnitPasswordStatusEntity();
		
		if (jsonObject.has(STATUS_CODE)) {
			bean.statusCode = jsonObject.getString(STATUS_CODE);
		}
		if (jsonObject.has(MSG)) {
			bean.msg = jsonObject.getString(MSG);
		}
		return bean;
	}

	public ArrayList<BigUnitPasswordStatusEntity> parseJSONForBigUnit(JSONObject jsonObject)
			throws JSONException {
		ArrayList<BigUnitPasswordStatusEntity> mList = new ArrayList<BigUnitPasswordStatusEntity>();
		BigUnitPasswordStatusEntity bean = null;
		JSONArray jsonArray = jsonObject.getJSONArray("data");
		for (int i = 0; i < jsonArray.length(); i++) {
			bean = new BigUnitPasswordStatusEntity();
			JSONObject jObject = (JSONObject) jsonArray.get(i);

			if (jObject.has(EXAMINE_STATUS)) {
				bean.examineStatus = jObject.getString(EXAMINE_STATUS);
			}
			if (jObject.has(REFUSEREASON)) {
				bean.refuseReason = jObject.getString(REFUSEREASON);
			}
			if (jObject.has(BOOT_PWD)) {
				bean.bootPwd = jObject.getString(BOOT_PWD);
			}
			if (jObject.has(IDENTITY_CODE)) {
				bean.identityCode = jObject.getString(IDENTITY_CODE);
			}
			if (jObject.has(BARCODE)) {
				bean.barcode = jObject.getString(BARCODE);
			}
			if (jObject.has(SEARCH_DATE)) {
				bean.searchDate = jObject.getString(SEARCH_DATE);
			}
			if (jObject.has(VERIFY_STATUS)) {
				bean.verifyStatus = jObject.getString(VERIFY_STATUS);
			}
			mList.add(bean);
		}

		return mList;

	}
}
